Imports MIMS.WRS.Entities
Imports MIMS.WRS.Business
Imports MyFramework

Namespace Components


Public Class MailService

        Public Shared Sub CheckAndSendPaymentNotPaidMail()
            Try
            Dim notPaidItems As ShippingStatusReportCollection = ShippingStatusReportService.GetPaymentNotPaidList()

            If (notPaidItems.Count > 0) Then
                Dim notPaidMail As PaymentNotPaidMail = New PaymentNotPaidMail

                For Each ssr As ShippingStatusReport In notPaidItems
                    notPaidMail.ShippedDate = ssr.ShippingDate.ToShortDateString()
                    notPaidMail.POMUKNumber = ssr.SuppOrderNo
                    notPaidMail.Send()
                Next
                End If
            Catch ex As Exception
                Logger.Error("Failed to run CheckAndSendPaymentNotPaidMail", ex)
            End Try
        End Sub

        Public Shared Sub CheckAndSendDocNotReceivedMail()
            Try
                Dim items As ShippingStatusReportCollection = ShippingStatusReportService.GetDocNotReceivedList()

                If (items.Count > 0) Then
                    Dim docNotReceivedMail As docNotReceivedMail = New docNotReceivedMail

                    For Each ssr As ShippingStatusReport In items
                        docNotReceivedMail.ETADate = ssr.ETA.ToShortDateString()
                        docNotReceivedMail.POMUKNumber = ssr.SuppOrderNo
                        docNotReceivedMail.Send()
                    Next
                End If
            Catch ex As Exception
                Logger.Error("Failed to run CheckAndSendDocNotReceivedMail", ex)
            End Try
        End Sub

        Public Shared Sub CheckAndSendETAHasPastMail()
            Try
                Dim items As ShippingStatusReportCollection = ShippingStatusReportService.GetETAHasPastList()

                If (items.Count > 0) Then
                    Dim ETAHasPastMail As ETAHasPastForALongTimeMail = New ETAHasPastForALongTimeMail

                    For Each ssr As ShippingStatusReport In items
                        ETAHasPastMail.ETADate = ssr.ETA.ToShortDateString()
                        ETAHasPastMail.POMUKNumber = ssr.SuppOrderNo
                        ETAHasPastMail.Send()
                    Next
                End If
            Catch ex As Exception
                Logger.Error("Failed to run CheckAndSendETAHasPastMail", ex)
            End Try
        End Sub
    End Class

End Namespace